package com.hxzy.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author wzm
 * @create 2023-10-13 11:12
 * project_name:stu_sys
 */
//@WebFilter(urlPatterns = "/*")  //标识是一个过滤器才能工作 执行哪些路径需要过滤
public class HelloFilter implements Filter {
    //初始化方法
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init初识化操作");
    }

    //过滤器工作的方法
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("过滤器过滤到了请求");
        //进行了很多处理
        //放行通过
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("响应回来");

    }

    //销毁的方法
    @Override
    public void destroy() {
        System.out.println("销毁了");
    }
}
